package cn.lei.uicontrols;

import android.app.TimePickerDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TimePicker;

public class AtyUsingTimerPicker extends AppCompatActivity {

    private Button btnSelectTime;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aty_using_timer_picker);

        btnSelectTime = (Button) findViewById(R.id.btnSelectTime);
        btnSelectTime.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new TimePickerDialog(AtyUsingTimerPicker.this, new TimePickerDialog.OnTimeSetListener() {
                    @Override
                    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
//                        btnSelectTime.setText(String.format("%s:%s", timeFormat(hourOfDay), timeFormat(minute)));
                        btnSelectTime.setText(String.format("%02d:%02d", hourOfDay, minute));
                    }
                }, 21, 57, true).show();
            }
        });
    }

/*
    public String timeFormat(int value) {
        return value >= 10 ? "" + value : "0" + value;

    }
*/
}
